﻿@*
    TicketDesk - Attribution notice
    Contributor(s):

         Stephen Redd (stephen@reddnet.net, http://www.reddnet.net)
         Ashley Medway (https://github.com/AshleyMedway)

    This file is distributed under the terms of the Microsoft Public
    License (Ms-PL). See http://opensource.org/licenses/MS-PL
    for the complete terms of use.

    For any distribution that contains code from this file, this notice of
    attribution must remain intact, and a copy of the license must be
    provided to the recipient.
*@

@using Microsoft.AspNet.Identity
@using TicketDesk.Domain.Model
@using TicketDesk.IO
@model Ticket

@section title
{
    Ticket #@Model.TicketId
}

@section scripts
{
    @Styles.Render("~/content/editor")
    @Styles.Render("~/content/select2")
    @Styles.Render("~/content/summernote")
    @Scripts.Render("~/bundles/editor")
    @Scripts.Render("~/bundles/select2")
    @Scripts.Render("~/bundles/markdown")
    @Scripts.Render("~/bundles/editticket")
    @Scripts.Render("~/bundles/summernote")


    <script type="text/javascript">

        $(document).ready(function() {
            $.ajaxSetup({ cache: false });
            var tdConfig = {
                loadActivityUrl: '@Url.Action("LoadActivity", "TicketActivity", new {ticketId = Model.TicketId})',
                activityButtonsUrl: '@Url.Action("ActivityButtons", "TicketActivity", new {ticketId = Model.TicketId})',
                eventPanelUrl: '@Url.Action("TicketEvents", "Ticket", new {ticketId = Model.TicketId})',
                loadDetailsUrl: '@Url.Action("TicketDetails", "Ticket", new {ticketId = Model.TicketId})',
                attachmentsPanelUrl: '@Url.Action("TicketFiles", "Ticket", new {ticketId = Model.TicketId})',
                changeTicketSubscription: '@Url.Action("ChangeTicketSubscription", "Ticket", new {ticketId = Model.TicketId})',
                isSubscribed: @(Model.TicketSubscribers.Any(s => s.SubscriberId == User.Identity.GetUserId()) ? "true" : "false"),
                uploaderConfig: {
                    dropzoneUploadUrl: '@Url.Action("Upload", "File")',
                    getAttachmentsUrl: '@Url.Action("GetAttachmentsInfo", "File")',
                    defaultThumbnailUrl: '@Url.Content("~/content/images/general-file.png")',
                    deleteFileUrl: '@Url.Action("Delete", "File")',
                    ticketId: @Model.TicketId
                    },
                tagsConfig: {
                    tagAutoCompleteUrl: '@Url.Action("TagList", "AutoComplete")',
                },
                detailsConfig: {
                    isHtml: @(Model.IsHtml ? "true" : "false")
                    },
                isEditorDefaultHtml: @(ViewBag.IsEditorDefaultHtml? "true" : "false")
                };
            window.editTicket.activate(tdConfig);
        });
    </script>
}

<main role="main">
    <div id="ticketDetailPanel" class="panel panel-info">
        @Html.Action("TicketDetails", new { ticketId = Model.TicketId })
    </div>

    <div class="panel panel-success">
        <div class="panel-heading" style="">
            <div class="btn-toolbar" role="toolbar">
                <div id="activityButtonsPanel">
                    @Html.Action("ActivityButtons", "TicketActivity", new {ticketId = Model.TicketId})
                </div>
            </div>
        </div>
        <section id="activityPanel"></section>
    </div>
    <div id="attachmentsPanel">
        @Html.Action("TicketFiles", new { ticketId = Model.TicketId })
    </div>
    <div class="panel panel-info">
        <div class="panel-heading panel-title" style="padding: 3px 5px;">
            Activity
        </div>
        <div id="eventPanel" class="panel-body">
            @Html.Action("TicketEvents", new { ticketId = Model.TicketId })
        </div>
    </div>
    <p>
        @Html.ActionLink("Back to List", "Index", "TicketCenter")
    </p>
</main>
